package frist50;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class T0004 {
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {


        int m=nums1.length;
        int n=nums2.length;
        int[] h=new int[m+n];
        int mod=(m+n)/2;
        for (int i = 0; i <nums1.length ; i++) {
            h[i]=nums1[i];
        }
        for (int i = 0; i <nums2.length ; i++) {
            h[i+nums1.length]=nums2[i];
        }
        Arrays.sort(h);
        if ((m+n)%2==1){
            return (double)h[mod];
        }else {
            return ((double)h[mod-1]+(double)h[mod])/2;
        }
    }
    @Test
    public void test() {
        int [] nums1={1,3};
        int[] nums2={2};
        System.out.println(findMedianSortedArrays(nums1,nums2));


    }
}
